package com.gitee.wsl.doc.prosemirror.model.node.ext

import com.gitee.wsl.doc.prosemirror.model.node.Node

fun Node.findNode(f: (Node) -> Boolean): Pair<Node, Int>? {
    var result: Pair<Node, Int>? = null
    descendants { node, pos, _, _ ->
        if (f(node)) {
            result = node to pos
        }
        true
    }
    return result
}